<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/public/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>收款管理</title>
<% request.setAttribute("menu", 1); %>
<%@ include file="/WEB-INF/page/public/contentmeta.jsp"%>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="<%=basePath%>css/global.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>plugins/font-awesome/css/font-awesome.min.css"/>
<link rel="stylesheet" href="<%=basePath%>css/system.css" media="all"/>
<link rel="stylesheet" href="<%=basePath%>css/tab.css" media="all" />
<style type="text/css">

/* 收款弹窗 */
.collection-money { display:none; }




</style>
</head>
<body>

<div class="admin-tab admin-user">
    <div class="tab-condition">
        <form class="layui-form clefix" id="htform" action="/finance/paymentlisturl" method="post">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="text" name="keyWord" id="keyWord"  autocomplete="off" placeholder="请输入关键字" class="layui-input" value="${pager.params.KeyWord }">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block" style="width:170px;">
                    <input type="text" style="width:170px;" name="arrivaltime" id="arrivaltime"  placeholder="预计到帐时间" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})" value="${pager.params.arrivaltime}">
                </div>
            </div>
            <div class="layui-form-item">
	            <input name="skipToPage" id="skipToPage"  type="hidden" value="${pager.pageNo}">
				<input type="hidden" id="pageNo" name="pageNo" value="${pager.pageNo}">
				<input type="hidden" id="totalPage" name="totalPage" value="${pager.totalPages}">
				<input type="hidden" id="type" name="type" value="${type}">
                <button class="layui-btn TM-btn-search searchbtn" lay-submit="" lay-filter="demo2"><i class="layui-icon layui-unselect layui-tab-close">&#xe615;</i>搜索</button>
               <button class="layui-btn refreshbtn"  type="button"><i class="layui-icon layui-unselect layui-tab-close ">&#x1002;</i>刷新</button>  
            </div>
        </form>
    </div>
    <div class="layui-field-box">
        <table class="site-table table-hover TM-table-news">
            <thead>
            <tr>
                <th style="width:5%;">编号</th>
                <th style="width:20%;">合作方</th>
                <th style="width:10%;">收款金额</th>
                <th style="width:10%;">预计到账时间</th>
                <th style="width:10%;">收款方式</th>
                <th style="width:10%;">收款类型</th> 
                <th style="width:10%;">操作人</th> 
                <th style="width:25%;">操作</th>
            </tr>
            </thead>
            <tbody>
	             <c:forEach var="obj" items="${pager.resultList}" varStatus="o1">
		            <tr>
			                <td>${o1.index+1}</td>
			                <td>${obj.customerInfo.cname}</td>
			                <td><fmt:formatNumber value="${obj.totalamount}" pattern="#,#00"/>元</td>
			                <td>${obj.arrivaltime.substring(0,10)}</td> 
			                <td>
			                	<c:if test="${obj.moneytype == 0}">预付款</c:if>
		               			<c:if test="${obj.moneytype == 1}">全款</c:if>
		               			<c:if test="${obj.moneytype == 2}">中期款</c:if>
		               			<c:if test="${obj.moneytype ==3}">公示款</c:if>
		               		</td>
			                <td>${obj.paytype}</td>
			                <td>${obj.createuserName}</td>
			                <td><a class="layui-btn layui-btn-normal layui-btn-mini  showcontractinfo" data="${obj.contractid}"   type="button">查看</a></td>
		            </tr>
	            </c:forEach>
	            
	            <%--  <c:forEach var="obj" items="${pager.resultList}" varStatus="o1">
	            	<tr>
		                <td>${o1.index+1}</td>
		                <td>${obj.customerInfo.cname}</td>
		                <td><fmt:formatNumber value="${obj.totalamount}" pattern="#,#00"/>元</td>
		                <td><c:if test="${obj.type==0}">无</c:if><c:if test="${obj.type==1}"><fmt:formatNumber value="${obj.servicecharge}" pattern="#,#00"/>元</c:if></td>
		                <td><dic:cf type="1" name="contract_type" value="${obj.contracttype}"/></td>
		                <td><c:if test="${obj.totalmoney>0}">${obj.type==0?"-":"+"}<fmt:formatNumber value="${obj.totalmoney}" pattern="#,#00"/>元</c:if><c:if test="${obj.totalmoney==null||obj.totalmoney<1}">无记录</c:if></td>
		                <td><dic:cf type="1" name="contract_type" value="${obj.state}"/></td>
		                <td>${obj.signingtime.substring(0,10)}</td>	
		                <td>
		                	<a class="layui-btn layui-btn-normal layui-btn-mini  showcontractinfo" data="${obj.type==0? obj.pid:obj.id}"   type="button">查看</a>
		                    <c:if test="${obj.state==1||obj.state==2}">
		                    	<c:if test="${obj.type==0}">
			                	  <a data-method="offset" data-type="auto" class="layui-btn layui-btn-normal layui-btn-mini dksqbtn"  data="${obj.id}" dtamount="${obj.totalamount}" dmoney="${obj.totalamount-obj.totalmoney}"  dcusid="${obj.cusid}"  dname="${obj.createuserName}">付款</a>
			                	</c:if>
			                	<c:if test="${obj.type==1}">
			                	   <a data1="${obj.id}" data2="${obj.customerInfo.id}" data-method="offset" data-type="auto" dtamount="${obj.totalamount}" dmoney="${obj.totalamount-obj.totalmoney}" class="layui-btn layui-btn-normal layui-btn-mini collectionbtn">收款</a>
			                	</c:if>
		                    </c:if>
		                    <c:if test="${obj.state>3}">
		                       <a data-method="offset" data-type="auto" class="layui-btn layui-btn-normal layui-btn-mini">上传合同</a>
		                    </c:if> 
		                </td>
		            </tr>
	             </c:forEach> --%>
            </tbody>
        </table>
        <div class="admin-table-page">
            <div id="page" class="page"></div>
        </div>	
    </div>
</div>
 


<script>
    layui.config({
        base: 'plugins/layui/modules/'
    });
    layui.use(['element','laypage','form','laydate','layer'], function() {
        var $ = layui.jquery,
                laypage = layui.laypage,
                layer = layui.layer,
                element = layui.element(); //Tab的切换功能，切换事件监听等，需要依赖element模块
        var form = layui.form();
                
                
        //分页
        var pageNo = $("#pageNo").val();
    	var totalPage = $("#totalPage").val();
    	laypage({
            cont: 'page',
            curr: pageNo//'${pager.pageNo}'
            ,pages: totalPage//'${pager.totalPages}' //总页数
            ,
            groups: 5 //连续显示分页数
            ,
            skip: true,
            jump: function(obj, first) {
                //得到了当前页，用于向服务端请求对应数据
                var curr = obj.curr;
                if(!first) {
                	$("#skipToPage").val(curr);
                	$("#htform").submit();
                }
            }
        }); 
                
                
        //更新渲染
        form.render();
        //设置收款的合同id,cusid为空
        $(".contractid").val("");
        $(".cusid").val("");
 
		//点击查看合同详情
        $('.showcontractinfo').on('click',function(){
        	var id =  $(this).attr("data"),
        	    url =  "/customer/contractinfo?id="+id;
            parent.layer.open({
                title:'合同详情',
                type:2,
                content:url,
                shadeClose:true,
                btnAlign:'c',
                area:['80%','90%']
            });
        });
                
    	//点击搜索
        $(".searchbtn").on("click",function(){
      	  $("#skipToPage").val(1);
      	  form.submit();
        });
        
 
    });
</script>


</body>
</html>